import fs from 'fs'
function readFile(filePath = 'D:/download/3aa9be9a-16ed-3aca-35f9-0f71e75321df.zip') {
  const fileReadStream = fs.createReadStream(filePath, { highWaterMark: 10 * 1024 * 1024 })
  let count = 0;
  let dataBuffer = Buffer.from('')
  fileReadStream.on('data', (buffer) => {
    dataBuffer = Buffer.concat([dataBuffer, buffer])
    console.log(count++)
  });
  fileReadStream.on('end', () => {
    count = 0
    console.log(dataBuffer.toString().length);
    console.log('文件读取完成')
  })
  fileReadStream.on('error', console.log)
  return fileReadStream
}

function writeFile(filePath) {
  const fileWriteStream = fs.createWriteStream(filePath, { highWaterMark: 10 * 1024 * 1024 })
  return fileWriteStream
}
for (let i = 0; i < 300; i++) {
  readFile().pipe(writeFile(`../test/test${i}.zip`))
}
